#-------------------------------------#
#       对单张图片进行预测
#-------------------------------------#
from frcnn import FRCNN
from PIL import Image

import os
all_list=[]
# frcnn = FRCNN()
count=0
image_path="E:\\FasterRCNN\\faster-rcnn-pytorch-master\\img1"

for dir in os.listdir(image_path):
    if dir.endswith(".jpg"):
        imge_dir=os.path.join(image_path,dir)
        print(dir,end='')
        image = Image.open(imge_dir)
        frcnn = FRCNN()

        r_image= frcnn.detect_image(image)
#        all_list.append(list1)
        r_image.show()


# while True:
#     img = input('Input image filename:')
#     try:
#         image = Image.open(img)
#     except:
#         print('Open Error! Try again!')
#         continue
#     else:
#         r_image,list = frcnn.detect_image(image)
#         all_list.append(list)
#         r_image.show()
#         count=count+1
#         # if count==2:
# with open("E:\\FasterRCNN\\faster-rcnn-pytorch-master\\Txtdocument\\location.txt", "w") as f:
#     for i in all_list:
#         print(i)
#         for j in range(i):
#             f.write(str(j) + " ")
